\hypertarget{cc__mpc__coldstart__matrixevaluation__sparse_8m}{
\subsection{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m File Reference}
\label{dd/d07/cc__mpc__coldstart__matrixevaluation__sparse_8m}\index{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m@{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m}}
}


The function evaluates matrices like Hessian and F-\/matrix for the MPC controller.  


\subsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
function \hyperlink{cc__mpc__coldstart__matrixevaluation__sparse_8m_ae3a118b5a5e5a95fcb2958b61349b643}{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse} (in A\_\-e, in B\_\-e, in C\_\-e, in Nc, in Np)
\item 
function \hyperlink{cc__mpc__coldstart__matrixevaluation__sparse_8m_a486dada6654b90a97dc39ae30725a95c}{dedonahessian} (in A\_\-e, in B\_\-e, in C\_\-e, in Nc, in Np)
\end{DoxyCompactItemize}


\subsubsection{Detailed Description}
The function evaluates matrices like Hessian and F-\/matrix for the MPC controller. \begin{DoxyAuthor}{Author}
Mikhail Konnik 
\end{DoxyAuthor}
\begin{DoxyDate}{Date}
12 January 2012
\end{DoxyDate}
\hypertarget{dd/d07/cc__mpc__coldstart__matrixevaluation__sparse_8m_coldstartmatrixevaluation}{}\subsubsection{Cold Start of the MPC controller -\/ Hessian and F-\/matrix}\label{dd/d07/cc__mpc__coldstart__matrixevaluation__sparse_8m_coldstartmatrixevaluation}
Using a standard state space RHC formulation, the cost function $V_{N_p,N_c}$ for a state prediction horizon $N_p$ and control prediction horizon $N_c$ is:

$ V_{N_p,N_c} = \frac{1}{2}x^TC^T Cx + \frac{1}{2} X^T \mathcal Q X + \frac{1}{2} U^T \mathcal R U, \,\,\,\,\,\,\, X = [x_1, x_2, \dots x_{N_p}]^T, \,\,\,\,\,\,\, U = [u_0, u_1, \dots u_{N_c}]^T $

where $x$ denotes the current state (i.e., $x=x_0$). The matrices $\mathcal Q$ and $  R\$ are defined as:

$\mathcal Q = diag\{C^T C,C^T C,\dots P\} \mbox{ and } \mathcal R = diag\{R, R, \dots R\}, $

where the matrix $R$ is the penalty for the size of the control input, and the matrix $P$ is the penalty for missing the desired goal state (if the desired goal is zero). The penalty matrix for excessive control energy is $R = 10^{-12}\cdot I$. The horizons were set to $N_p=2$ for the state prediction horizon and $N_c =1$ for the control prediction horizon.

Define matrices $\Gamma$ and $\Omega$ as:

$ \Gamma = \left[ \begin{array}{cccc} B & 0 & \dots &0\\ AB & B & \dots &0\\ \vdots & \vdots & \ddots &\vdots\\ A^{N_p-1}B& A^{N_p-2}B& \dots & A^{N_p-N_c}B\\ \end{array} \right] $

and

$ \Omega = \left[ \begin{array}{c} A \\ A^2 \\ \vdots \\ A^{N_p} \\ \end{array} \right] $

The dynamics in \{eq:sys\} can be expressed over the prediction horizon in a vector form as:

$ X = \Gamma U + \Omega x. $

Substituting into the cost function we obtain:

$ V_{N_p,N_c} = \bar{V} + \frac{1}{2} U^T \mathbb H U + U^T\mathbb F x,$

where the term $\bar{V}$ is independent of \$U\$. The Hessian matrix $\mathbb{H}$ and the matrix $\mathbb{F}$ are defined as follows:

$ \mathbb{H} \triangleq \Gamma^T \mathcal Q \Gamma + \mathcal R, \,\,\,\,\,\,\ \mathbb{F} \triangleq \Gamma^T \mathcal Q \Omega .$ 

Definition in file \hyperlink{cc__mpc__coldstart__matrixevaluation__sparse_8m_source}{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m}.



\subsubsection{Function Documentation}
\hypertarget{cc__mpc__coldstart__matrixevaluation__sparse_8m_ae3a118b5a5e5a95fcb2958b61349b643}{
\index{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m@{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m}!cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse@{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse}}
\index{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse@{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse}!cc_mpc_coldstart_matrixevaluation_sparse.m@{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m}}
\paragraph[{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse}]{\setlength{\rightskip}{0pt plus 5cm}function cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse (
\begin{DoxyParamCaption}
\item[{in}]{ A\_\-e, }
\item[{in}]{ B\_\-e, }
\item[{in}]{ C\_\-e, }
\item[{in}]{ Nc, }
\item[{in}]{ Np}
\end{DoxyParamCaption}
)}\hfill}
\label{dd/d07/cc__mpc__coldstart__matrixevaluation__sparse_8m_ae3a118b5a5e5a95fcb2958b61349b643}

\begin{DoxyParams}{Parameters}
\item[{\em A\_\-e}]= states evolution matrix. \item[{\em B\_\-e}]= input control matrix. \item[{\em C\_\-e}]= Output control matrix \item[{\em Nc}]= control prediction horizon. \item[{\em Np}]= state prediction horizon. \end{DoxyParams}

\begin{DoxyRetVals}{Return values}
\item[{\em H}]= Hessian matrix for the MPC \item[{\em F}]= F-\/matrix for the MPC \end{DoxyRetVals}
\hypertarget{cc__mpc__coldstart__matrixevaluation__sparse_8m_a486dada6654b90a97dc39ae30725a95c}{
\index{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m@{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m}!dedonahessian@{dedonahessian}}
\index{dedonahessian@{dedonahessian}!cc_mpc_coldstart_matrixevaluation_sparse.m@{cc\_\-mpc\_\-coldstart\_\-matrixevaluation\_\-sparse.m}}
\paragraph[{dedonahessian}]{\setlength{\rightskip}{0pt plus 5cm}function dedonahessian (
\begin{DoxyParamCaption}
\item[{in}]{ A\_\-e, }
\item[{in}]{ B\_\-e, }
\item[{in}]{ C\_\-e, }
\item[{in}]{ Nc, }
\item[{in}]{ Np}
\end{DoxyParamCaption}
)}\hfill}
\label{dd/d07/cc__mpc__coldstart__matrixevaluation__sparse_8m_a486dada6654b90a97dc39ae30725a95c}
